<?php include PATH_TPL."/tpl_header.html" ?>
<script type="text/javascript">
	$(function(){
		var uid       = '';
		var cid  = $("#class_id").val();
		var adminUrl  = '/index.php/admin/';
		
		$("#class-menu").addClass('in');
		$(".deleteBtn").click(function(){
			uid = $(this).attr('name');
			$('#submit').click(function() {
				location.href = adminUrl+'deleteStudent/id/'+uid;
			})
		})
		$('#downLoadBtn').click(function(){
			location.href = adminUrl+"downLoadStudent/cid/"+cid; 
		})
	})
</script>

<div class="header">
    <h1 class="page-title">班级管理</h1>
</div>
        
<ul class="breadcrumb">
    <li><a href="<?php echo SITE_ROOT?>admin/show-classes">班级管理</a> <span class="divider">/</span></li>
    <li class="active"><?php echo $class['classname']?></li>
</ul>

<div class="container-fluid">
    <div class="row-fluid">
		<div class="btn-toolbar">
		   	<a href="<?php echo SITE_ROOT?>admin/add-student" style="margin-right:5px;"><button class="btn btn-primary"><i class="icon-plus"></i>添加学生</button></a>
		    <button class="btn" id="downLoadBtn">导出</button>
		</div>
		<div class="well">
			<input type="hidden" value="<?php echo $class['class_id'] ?>" id="class_id">
		    <table class="table">
		    	<?php if (!empty($allStudent)) {?>
		      <thead>
		        <tr>
		          <th><?php echo $fieldName['uid']['comment'] ?></th>
		          <th><?php echo $fieldName['name']['comment'] ?></th>
		          <th><?php echo $fieldName['sex']['comment'] ?></th>
		          <th><?php echo $fieldName['position']['comment'] ?></th>
		          <th><?php echo $fieldName['email']['comment'] ?></th>
		          <th><?php echo $fieldName['phone']['comment'] ?></th>
		          <th style="width: 30px;">操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      	<?php foreach ($allStudent as $student) { ?>
		        <tr>
		          <td><?php echo $student['uid'] ?></td>
		          <td><?php echo $student['name'] ?></td>
		          <td><?php echo $sex[$student['sex']]?></td>
		          <td><?php echo $student['position']?></td>
		          <td><?php echo $student['email']?></td>
		          <td><?php echo $student['phone']?></td>
		          <td>
		              <a href="<?php echo SITE_ROOT.'admin/update-student/id/'.$student['uid'];?>"><i class="icon-pencil"></i></a>
		              <a href="#deleteBox" role="button" data-toggle="modal"><i class="icon-remove deleteBtn" name="<?php echo $student['uid'];?>"></i></a>
		          </td>
		        </tr>
		        <?php }?>
		      </tbody>
		      <?php }else{?>
		      <tr><td>暂无学生信息</td></tr>
		      <?php }?>
		    </table>
		</div>
		<a href="#" id="to-top"><i class="icon-circle-arrow-up"></i> Top</a>

		<!--删除警示框-->
		<div class="modal small hide fade" id="deleteBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		    <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		        <h3 id="myModalLabel">警告框</h3>
		    </div>
		    <div class="modal-body">
		        <p class="error-text"><i class="icon-warning-sign modal-icon"></i>你确定要删除这个学生么?</p>
		    </div>
		    <div class="modal-footer">
		        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
		        <button class="btn btn-danger" id="submit" >删除</button>
		    </div>
		</div>
		<!--警示框END-->
	</div>
</div>
<?php include PATH_TPL."/tpl_sidebar.html" ?>